package com.ruoyi.project.member.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.member.domain.LblCsUser;
import com.ruoyi.project.member.service.ILblCsUserService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户基本（常用）信息Controller
 * 
 * @author BaoL
 * @date 2023-03-23
 */
@RestController
@RequestMapping("/member/user")
public class LblCsUserController extends BaseController
{
    @Autowired
    private ILblCsUserService lblCsUserService;

    /**
     * 查询用户基本（常用）信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(LblCsUser lblCsUser)
    {
        startPage();
        List<LblCsUser> list = lblCsUserService.selectLblCsUserList(lblCsUser);
        return getDataTable(list);
    }

    /**
     * 导出用户基本（常用）信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:user:export')")
    @Log(title = "用户基本（常用）信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LblCsUser lblCsUser)
    {
        List<LblCsUser> list = lblCsUserService.selectLblCsUserList(lblCsUser);
        ExcelUtil<LblCsUser> util = new ExcelUtil<LblCsUser>(LblCsUser.class);
        return util.exportExcel(list, "user");
    }

    /**
     * 获取用户基本（常用）信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lblCsUserService.selectLblCsUserById(id));
    }

    /**
     * 新增用户基本（常用）信息
     */
    @PreAuthorize("@ss.hasPermi('member:user:add')")
    @Log(title = "用户基本（常用）信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LblCsUser lblCsUser)
    {
        return toAjax(lblCsUserService.insertLblCsUser(lblCsUser));
    }

    /**
     * 修改用户基本（常用）信息
     */
    @PreAuthorize("@ss.hasPermi('member:user:edit')")
    @Log(title = "用户基本（常用）信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LblCsUser lblCsUser)
    {
        return toAjax(lblCsUserService.updateLblCsUser(lblCsUser));
    }

    /**
     * 删除用户基本（常用）信息
     */
    @PreAuthorize("@ss.hasPermi('member:user:remove')")
    @Log(title = "用户基本（常用）信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lblCsUserService.deleteLblCsUserByIds(ids));
    }
}
